import sample_ctypes as sample
import numpy as np
from python_baway.common.xcommon import *
import array
import sys

sep('gcd')
a, b = 35, 42
xgcd = sample.gcd(a, b)
print(f'gcd({a}, {b}) = {xgcd}')

sep('in mandel')
print(f'{sample.in_mandel(0, 0, 500)}')
print(f'{sample.in_mandel(2.0, 1.0, 500)}')

sep('divide')
print(f'{sample.divide(42, 8)}')

sep('avg')
print(f'list: {sample.avg([1, 2, 3, 4])}')
print(f'tuple: {sample.avg((1, 2, 3, 4))}')
print(f'_avg(ndarr, num): {sample._avg(np.array([1, 2, 3, 4], dtype=float), 4)}')
print(f'ndarr: {sample.avg(np.array([1, 2, 3, 4], dtype=float))}')
print(f'by numpy: {np.array([1, 2, 3, 4], dtype=float).mean()}')

sep('avg on array')
arr = array.array('d', [1, 2, 3, 4])
print(f'array: {sample.avg(arr)}')

sep('distance')
p1 = sample.Point(1, 2)
print('p1', p1)
p2 = sample.Point(2, 3)
print('p2', p2)
dist = sample.distance(p1, p2)
print('dist', dist)

sep('distance_my')
p1 = sample.Point(100, 200)
print('p1', p1)
p2 = sample.Point(200, 300)
print('p2', p2)
# sys.exit(0)
dist = sample.distance_my(p1, p2)
print('dist', dist)
